/*
 * @Author: qianmingtian
 * @Date: 2020-06-28 17:35:12
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-06-29 09:00:13
 * @FilePath: \qianmingtian.github.io\code\java\algrothms\Prime.java
 * @ 判断是不是素数
 *      1.暴力遍历到该数的sqrt(num)
 *      2.筛子算法 
 */
package algrothms;

import java.util.BitSet;

public class Prime {
    private static boolean IsPrimeBy2(int num) {
        if (num <= 0) {
            return false;
        }

        return true;
    }

    private BitSet PrimeNumInN(int N) {
        BitSet bt = new BitSet(N + 1);
        for (int i = 2; i <= N; i++)
            bt.set(1);  //set all bit show it is prime

        int bound = (int) Math.sqrt(N) + 1;

        for (int i = 2; i <= bound; i++) {
            if(!bt.get(i)){
                

            }
        }

        return bt;

    }

    private static boolean IsPrime(int num) {

        if (num <= 0) {
            return false;
        }

        int bound = (int) Math.sqrt(num) + 1;

        for (int i = 2; i < bound; i++) {
            if (0 == num % i) {
                return false;
            }
        }

        return true;
    }

    public static void main(String[] args) {
        int num = 7;
        if (IsPrime(num)) {
            System.out.println(num + " it is prime !");
        }
    }
}/*
  * @Author: qianmingtian
  * 
  * @Date: 2020-06-28 17:35:12
  * 
  * @LastEditors: qianmingtian
  * 
  * @LastEditTime: 2020-06-28 17:35:13
  * 
  * @FilePath: \qianmingtian.github.io\code\java\algrothms\IsPrime.java
  */
